<template>
	<div class="logins">
		<div class="login">
			<div class="login_content">
				<div class="login_content_top">
					<div class="logo"><img src="@/assets/logo(1).png" /></div>
					<div class="logo_title">后台管理系统</div>
				</div>
				<div class="login_content_center">
					<div class="input">
						<img src="@/assets/user.png" />
						<input type="text" placeholder="请输入登录账号" v-model="form.username">
					</div>
					<div class="input">
						<img src="@/assets/password.png"/>
						<input type="password" placeholder="请输入您的密码" v-model="form.password">
					</div>
				</div>
				<div class="login_content_bottom">
					<button @click="login">登录</button>
				</div>
			</div>
		</div>
	</div>
</template>

<script>
	export default {
		data() {
			return {
				form: {					// 用户账号密码
					username:'admin1',		// 用户名
					password:'6ea65109fb66569a1afa5159c5f3ab7e',		// 密码
				}
			}
		},
		methods: {
			login() {
				if(this.form.userName == '') {
					this.$message({
					  showClose: true,
					  message: '请输入账号',
					  type: 'error'
					});
				}else if(this.form.passWord == '') {
					this.$message({
					  showClose: true,
					  message: '请输入密码',
					  type: 'error'
					});
				};
				let username = this.form.username;
				let password = this.form.password;
				this.$axios.post('/api/admin/base/login', {username,password})
				.then(res => {
					console.log(res);
					if(res.data.code == 1) {
						localStorage.setItem('liankun_user',JSON.stringify(res.data.data.token));
						this.$router.push({path:'/manaindex'})
					}
				})
				.catch(err => {
					console.log(err);
				})
			},
		},
	}
</script>

<style lang="less" scoped="scoped">
	@import 'login.less';
</style>
